﻿using System;
using System.Diagnostics;
namespace Commons.log
{

    public class CommonLog : Commons.log.ILog
    {

        public static ILog GetLogger()
        {
            return new CommonLog(new StackFrame(1).GetMethod().ReflectedType);
        }

        log4net.ILog log = null;

        private static Boolean isConfigurado = false;
        
        private CommonLog(Type type)
        {
            log = log4net.LogManager.GetLogger(type);
            configurar();
        }

        private void configurar()
        {
            if (!isConfigurado)
            {
                log4net.Config.BasicConfigurator.Configure();
                isConfigurado = true;
            }
        }

        public void Debug(String message)
        {
            log.Debug(message);
        }
        public void Debug(String message, Exception e)
        {
            log.Debug(message, e);
        }

        public void Info(String message)
        {
            log.Info(message);
        }
        public void Info(String message, Exception e)
        {
            log.Info(message, e);
        }

        public void Warn(String message)
        {
            log.Warn(message);
        }
        public void Warn( String message, Exception e)
        {
            log.Warn(message, e);
        }

        public void Error(String message)
        {
            log.Error(message);
        }
        public void Error(String message, Exception e)
        {
            log.Error(message, e);
        }

        public void Fatal(String message)
        {
            log.Fatal(message);
        }
        public void Fatal(String message, Exception e)
        {
            log.Fatal(message, e);
        }



    }


}
